home *** CD-ROM | disk | FTP | other *** search
/ Beginning Mac Programming / Beginning Mac Programming.bin / pc / Open Me for REALbasic 3 / REALbasic 3.2 / Example Projects / Techniques / Examples by Thomas Tempelmann / TT's MemoryBlock Extension / MemoryBlock Plugin - ReadMe < prev    next >
Encoding:
Text File  |  1999-07-06  |  5.2 KB  |  108 lines

  1. TT's MemoryBlock Plugin for REALbasic
  2.  
  3. General Information
  4.  
  5. By Thomas Tempelmann
  6. Current version: 1.0 (July 6, 1999)
  7.  
  8. This is freeware. Use it as you like.
  9. (And if you have created some nice things, think about sharing them, too!)
  10.  
  11. This is a Plugin for REALbasic version 2 or later (it does not work with REALbasic v1!). Plugins contain usually low-level code that cannot be written using the REALbasic language directly.
  12.  
  13. The plugin and the sample RB program were created and tested using CodeWarrior Pro 3 and REALbasic 2.0.2.
  14.  
  15. More REALbasic examples can be found on my Web Site at
  16.  
  17.   <http://www.tempel.org/rb/>
  18.  
  19. Enjoy!
  20.  
  21. Overview
  22.  
  23. This Plugin extends the functionality of the RB-internal class MemoryBlock.
  24.  
  25. The addition you will most likely appreciate is that you can now copy Strings and Double (64 bit floating point) values from and to a MemoryBlock. Without this plugin, only simple data types, like Integers, could be accessed in a MemoryBlock.
  26.  
  27. There's also a function to inquire the Size of the MemoryBlock, and some powerful functions to copy big chunks of memory around in MemoryBlocks and even to and from Mac's main memory.
  28.  
  29. Installation
  30.  
  31. 1. Quit REALbasic if it is running
  32.  
  33. 2. Place the file TT's MemoryBlock-Plugin into a folder called Plugins, which resides in the same folder where your REALbasic application is.
  34.  
  35. 3. Now you can launch REALbasic again. The methods, controls or classes described below will be available to your RB applications and to the RB demo project that came with this plugin.
  36.  
  37.  
  38. MemoryBlock Properties & Methods added by this Plugin
  39.  
  40. Note: If you do not understand certain functions provided here, look into the enclosed demo projects for examples.
  41.  
  42. • Size as Integer
  43.  
  44. Returns the size of the MemoryBlock (it is the same size value that was specified when creating the object calling the function NewMemoryBlock). If this value is zero, then the MemoryBlock was not allocated by NewMemoryBlock, but rather retrieved from a Shared Lib call.
  45.  
  46. • DoubleValue(offset as Integer) as Double
  47.  
  48. Similar to the other properties, like SingleValue, or Long, this one allows you to access 64 Bit (8 Byte) IEEE floating point numbers in a MemoryBlock.
  49.  
  50. • GetString(offset as Integer, numBytes as Integer) as String
  51.  
  52. Copies the specified amount of bytes from the MemoryBlock and returns them as a String object.
  53.  
  54. • SetString(str as String, offset as Integer)
  55.  
  56. Overwrites the contents of the MemoryBlock with the provided string. Contents of the MemoryBlock outside of the string's dimension remain unchanged.
  57.  
  58. Note: You must make sure that the copied bytes fit inside the block (if they don't, your application or even the whole system can crash).
  59.  
  60. • CopyBytes(srcOfs as Integer, numBytes as Integer, destOfs as Integer)
  61.  
  62. Copies the specified amount of bytes inside the MemoryBlock.
  63.  
  64. Note: You must make sure that the copied bytes fit inside the block (if they don't, your application or even the whole system can crash).
  65.  
  66. • CopyBytes(srcOfs as Integer, numBytes as Integer, destBlk as MemoryBlock, destOfs as Integer)
  67.  
  68. Copies the specified amount of bytes into a second MemoryBlock.
  69.  
  70. Note: You must make sure that the destination block is large enough to hold the copied bytes (if not, your application or even the whole system can crash).
  71.  
  72. • CopyBytesToMacPtr(srcOfs as Integer, numBytes as Integer, destPtr as Integer)
  73.  
  74. Copies the given amount of bytes from the MemoryBlock to the given address in the Mac's memory address space.
  75.  
  76. Note: Be careful where you copy the data to - you can easily crash your computer if you write to the wrong address space.
  77.  
  78. • CopyBytesFromMacPtr(srcPtr as Integer, numBytes as Integer, destOfs as Integer)
  79.  
  80. Copies the given amount of bytes from the given address in the Mac's memory address space into the MemoryBlock.
  81.  
  82. Note: Make sure that the destination block is large enough to hold the copied bytes (if not, your application or even the whole system can crash).
  83.  
  84. • CopyBytesToMacHandle(srcOfs as Integer, numBytes as Integer, destPtr as Integer)
  85. • CopyBytesFromMacHandle(srcPtr as Integer, numBytes as Integer, destOfs as Integer)
  86.  
  87. Same as CopyBytesToMacPtr and CopyBytesFromMacPtr, only that the memory address is a so-called Handle (see documentation about the MacOS Memory Manager), which is double-referenced.
  88.  
  89.  
  90. Plugin Programming Information
  91.  
  92. The plugin code is a Metrowerks CodeWarrior Pro 3 (IDE 3.1) project.
  93. If you have an older CW version that refuses to open the prj file, then create a new and set/enable the following prj options:
  94. • create 68K target (set to 68K linker)
  95. • prj type: Code Resource, File Name "CatalogSearch-Plugin", Creator "SfTg", Type "RBPl", ResType "PL68", ResID "128", Extended Resource, Header Type "Standard"
  96. • C/C++ language settings: Prefix File "MacHeaders.h"
  97. • 68K Processor: 68020 Codegen, Code Model "Smart", Struct Alignm. "PowerPC", 4-Byte Ints, 8-Byte Doubles, MPW C Call. Conv.
  98. • 68K Linker: Link Single Segment, Merge Compiler Glue…, Dead-strip Static Init Code
  99. • Add the files "Plugin Source.cpp", "PluginMain.cpp", "MacOS.lib", "Version Info.rsrc" and a 68K C lib with (4i_8d) in its name to the project.
  100.  
  101. To compile the project, you also need to have the "Plugin SDK" available, which you can download from RB's website.
  102.  
  103.  
  104. Revision history
  105.  
  106. July 6, 1999, v1.0:
  107.     First release.
  108.